<template>
  <div class="demo01">
    <el-button @click="clickFlyto">故宫</el-button>
    <el-button @click="demo01Click">轮廓</el-button>
    <el-button @click="clickWaKeng">挖坑</el-button>
    <el-button @click="clickPIn">点位</el-button>
    <el-button @click="clickClear">清除</el-button>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  methods: {
    // 飞入
    clickFlyto() {
      // 飞入到故宫
      earth.czm.viewer.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(
          116.38918,
          39.91123,
          2394.5641509064294
        ),
      });
    },
    demo01Click() {
      earth.postProcess.silhouette.enabled =
        !earth.postProcess.silhouette.enabled;
      // var obj = {
      //   ref: "Models",
      //   czmObject: {
      //     xbsjType: "Model",
      //     xbsjGuid: "52f0124c-37c0-49c5-883a-294ba2ddc4d4",
      //     name: "模型",
      //     url: "../assets/aaa.glb",
      //     minimumPixelSize: 129,
      //     distanceDisplayCondition: [0, 50000000],
      //     xbsjPosition: [
      //       0.7989509198128153, 0.8593174906126755, 28.78704810013864,
      //     ],
      //   },
      // };
      // earth.sceneTree.root.children.push(obj);
      // //   earth.czm.viewer.entities.add(obj);
      // var model1 = earth.sceneTree.$refs.Models.czmObject;
      // console.log(earth.czm.viewer);
      // earth.czm.viewer.camera.flyTo({
      //   destination: Cesium.Cartesian3.fromDegrees(
      //     (0.8593174906126755 * 180) / Math.PI,
      //     (0.7989509198128153 * 180) / Math.PI,
      //     500
      //   ),
      // });
    },
    clickWaKeng() {
      //创建一个挖坑对象
      let cutsurface = new XE.Obj.CutSurface(earth);
      // 给对象赋值名称
      cutsurface.name = "挖坑";
      // 对象的编辑状态
      cutsurface.autoRegisterEditing = true;
      // 是否创建状态
      cutsurface.isCreating = true;
      // 创建属性
      cutsurface.creating = true;
      // 这里是绑定属性，绑定的是我们挖坑对象要那个模型上面挖去，这个模型可以是地形、瓦片等
      earth.sceneTree.$refs["GuGong"].czmObject.xbsjFlattenGuid =
        cutsurface.discardGuid;
      // 这里就是打印我们这个对象的xbsjGuid。我们根据这个对象的guid去获取对象earth.getObject("xbsjGuid")
      console.log(cutsurface.xbsjGuid);
    },
    clickPIn() {
      let pin = new XE.Obj.Pin(earth);
      pin.name = "兴趣点";
      pin.creating = true;
      // console.log(pin.xbsjGuid);
    },
    clickClear() {
      // 使用范例
      // 这样写的好处是，一旦对象销毁，会同时将引用该对象的变量同时置为undefined，防止再次使用。
      // this._myObject = this._myObject && this._myObject.destroy();
      console.log(earth.getObject("12312312313131313213"));
    },
  },
};
</script>

<style>
</style>